package job.gfp.ranks_v2.algorithm;

import job.gfp.ranks_v2.RanksV2_Algorithm;
import job.gfp.ranks_v2.RanksV2_Data;
import mapred.config.JobConfig;
import util.FeatureMap;

public class RanksV2_PageRank implements RanksV2_Algorithm {

    @Override
    public String getName() {
        return "pPageRank";
    }

    @Override
    public String[] getFields() {
        return new String[] { "Rank", "OutDegree" };
    }

    @Override
    public RanksV2_Data initialize(String source, FeatureMap targets, JobConfig config) {
        RanksV2_Data ret = new RanksV2_Data(this);
        
        ret.set("Rank", 1);
        
        long outDegree = 0;
        for (String target : targets.featureSet()) {
            outDegree += targets.get(target);
        }
        ret.set("OutDegree", outDegree);
        
        return ret;
    }

}
